package org.sixtynine.stock.entity;

/**
 * @author Thilan
 * this class handle daily sector data
 */

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.DecimalMin;

import org.sixtynine.stock.fileupload.FileUploadData;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;

@Entity
@Table(name = "ANNUAL_SECTOR_DATA")
public class AnnualSectorData extends BaseEntity implements FileUploadData {

	private int id;

	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date date;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double closingValue;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double noOfTrades;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double volume;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double turnOver;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double open;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double high;

	@DecimalMin("0.00")
	@NumberFormat(style = Style.NUMBER, pattern = "#,###,###,##0.00")
	private double low;

	private Sector sector;

	@Id
	@Column(name = "ID", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "DATE", nullable = false, length = 30)
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Column(name = "CLOSING_VALUE")
	public double getClosingValue() {
		return closingValue;
	}

	public void setClosingValue(double closingValue) {
		this.closingValue = closingValue;
	}

	@Column(name = "NUMBER_OF_TRADES")
	public double getNoOfTrades() {
		return noOfTrades;
	}

	public void setNoOfTrades(double noOfTrades) {
		this.noOfTrades = noOfTrades;
	}

	@Column(name = "VOLUME")
	public double getVolume() {
		return volume;
	}

	public void setVolume(double volume) {
		this.volume = volume;
	}

	@Column(name = "TURNOVER")
	public double getTurnOver() {
		return turnOver;
	}

	public void setTurnOver(double turnOver) {
		this.turnOver = turnOver;
	}

	@ManyToOne
	@JoinColumn(name = "SECTOR_ID")
	public Sector getSector() {
		return sector;
	}

	public void setSector(Sector sector) {
		this.sector = sector;
	}

	@Override
	public boolean equals(Object obj) {
		return (id == ((AnnualSectorData) obj).getId());
	}

	@Column(name = "OPEN")
	public double getOpen() {
		return open;
	}

	public void setOpen(double open) {
		this.open = open;
	}

	@Column(name = "HIGH")
	public double getHigh() {
		return high;
	}

	public void setHigh(double high) {
		this.high = high;
	}

	@Column(name = "LOW")
	public double getLow() {
		return low;
	}

	public void setLow(double low) {
		this.low = low;
	}

}
